<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Optimal doping profile optimization</title>
<link rel="canonical" href="/Users/mcgrant/Projects/CVX/examples/gp_tutorial/html/basic_odp.html">
<link rel="stylesheet" href="../../examples.css" type="text/css">
</head>
<body>
<div id="header">
<h1>Optimal doping profile optimization</h1>
Jump to:&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#source">Source code</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#output">Text output</a>
&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#plots">Plots</a>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="../../index.html">Library index</a>
</div>
<div id="content">
<a id="source"></a>
<pre class="codeinput">
<span class="comment">% Boyd, Kim, Vandenberghe, and Hassibi, "A tutorial on geometric programming"</span>
<span class="comment">% Joshi, Boyd, and Dutton, "Optimal doping profiles via geometric programming"</span>
<span class="comment">% Written for CVX by Almir Mutapcic 02/08/06</span>
<span class="comment">% (a figure is generated)</span>
<span class="comment">%</span>
<span class="comment">% Determines the optimal doping profile that minimizes base transit</span>
<span class="comment">% time in a (homojunction) bipolar junction transistor.</span>
<span class="comment">% This problem can be posed as a GP:</span>
<span class="comment">%</span>
<span class="comment">%   minimize   tau_B</span>
<span class="comment">%       s.t.   Nmin &lt;= v &lt;= Nmax</span>
<span class="comment">%              y_(i+1) + v_i^const1 &lt;= y_i</span>
<span class="comment">%              w_(i+1) + v_i^const2 &lt;= w_i, etc...</span>
<span class="comment">%</span>
<span class="comment">% where variables are v_i, y_i, and w_i.</span>

<span class="comment">% discretization size</span>
M = 50;
<span class="comment">% M = 1000; % takes a few minutes to process constraints</span>

<span class="comment">% problem constants</span>
g1 = 0.42;
g2 = 0.69;
Nmax = 5*10^18;
Nmin = 5*10^16;
Nref = 10^17;
Dn0 = 20.72;
ni0 = 1.4*(10^10);
WB = 10^(-5);
C =  WB^2/((M^2)*(Nref^g1)*Dn0);

<span class="comment">% exponent powers</span>
pwi = g2 -1;
pwj = 1+g1-g2;

<span class="comment">% optimization variables</span>
cvx_begin <span class="string">gp</span>
  variables <span class="string">v(M)</span> <span class="string">y(M)</span> <span class="string">w(M)</span>

  <span class="comment">% objective function is the base transmit time</span>
  tau_B = C*w(1);

  minimize( tau_B )
  subject <span class="string">to</span>
    <span class="comment">% problem constraints</span>
    v &gt;= Nmin;
    v &lt;= Nmax;

    <span class="keyword">for</span> i = 1:M-1
      <span class="keyword">if</span>( mod(i,100) == 0 ), fprintf(1,<span class="string">'progress counter: %d\n'</span>,i), <span class="keyword">end</span>;
      y(i+1) + v(i)^pwj &lt;= y(i);
      w(i+1) + y(i)*v(i)^pwi &lt;= w(i);
    <span class="keyword">end</span>

    y(M) == v(M)^pwj;
    w(M) == y(M)*v(M)^pwi;
cvx_end

<span class="comment">% plot the basic optimal doping profile</span>
figure, clf
nbw = 0:1/M:1-1/M;
semilogy(nbw,v,<span class="string">'LineWidth'</span>,2);
axis([0 1 1e16 1e19]);
xlabel(<span class="string">'base'</span>);
ylabel(<span class="string">'doping'</span>);
text(0,Nmin,<span class="string">'Nmin '</span>, <span class="string">'HorizontalAlignment'</span>,<span class="string">'right'</span>);
text(0,Nmax,<span class="string">'Nmax '</span>, <span class="string">'HorizontalAlignment'</span>,<span class="string">'right'</span>);
disp(<span class="string">'Optimal doping profile is plotted.'</span>)
</pre>
<a id="output"></a>
<pre class="codeoutput">
 
Successive approximation method to be employed.
   For improved efficiency, SDPT3 is solving the dual problem.
   SDPT3 will be called several times to refine the solution.
   Original size: 785 variables, 343 equality constraints
   196 exponentials add 1568 variables, 980 equality constraints
-----------------------------------------------------------------
 Cones  |             Errors              |
Mov/Act | Centering  Exp cone   Poly cone | Status
--------+---------------------------------+---------
196/196 | 6.261e+00  2.045e+00  7.021e-11 | Solved
195/196 | 3.102e+00  1.096e+00  0.000e+00 | Solved
190/192 | 7.602e-01  4.952e-02  0.000e+00 | Solved
 97/160 | 8.235e-02  5.447e-04  0.000e+00 | Solved
 26/ 68 | 6.361e-03  3.211e-06  0.000e+00 | Solved
  1/  7 | 5.910e-04  2.224e-08  0.000e+00 | Solved
  0/  0 | 0.000e+00  0.000e+00  0.000e+00 | Solved
-----------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +1.57873e-12
 
Optimal doping profile is plotted.
</pre>
<a id="plots"></a>
<div id="plotoutput">
<img src="basic_odp__01.png" alt=""> 
</div>
</div>
</body>
</html>